How to run C program
2025-08-04
How to run C program on windows
- Visual studio has a built-in C compiler.
- Run
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64in cmd to set up the environment. Note: It cannot run on powershell 7+. - Use
clcommand to compile C files, e.g.,cl test.c -o test.exe. - Run the compiled program with
test.exe.
Alternative or must way on Windows
- Use developer powershell for VS2022 will resolve the above hacks.
- Just open a new terminal with
Developer Command Prompt for VS 2022orDeveloper PowerShell for VS 2022. - Then
clcommand will work without any additional setup.